#define CTHPDBG 1
#define HURTDBG 1

// for reference

/*
	// I want lung damage, rad damage, chemical and biological poisoning and individual limb damage
	lunghealth = 100
	radloss = 0
	chemloss = 0
	bioloss = 0
	hungerloss = 0

	head_h = 100
	torso_h = 100
	l_arm_h = 100
	r_arm_h = 100
	groin_h = 100
	l_leg_h = 100
	r_leg_h = 100

	canwalk = 1
	cancrawl = 1
	cangrasp_l = 1
	cangrasp_r = 1
	stunned = 0

	basespd = 50
	spddiv = 2
	running = 0

	hunger = 100
	metabolism = 1
	starving = 0

	hasradio = 1



*/

mob/proc/CalcTotHP()

	var/total1
	var/total2

	total1 = head_h + torso_h + l_arm_h + r_arm_h + groin_h + l_leg_h + r_leg_h
	total2 = total1 / 7

	if (CTHPDBG)
		world << total1
		world << total2

	return total2


mob/proc/Hurt(amm as num, tgt as text, dmg as num) // This thing handles damage and shit

	if (!dmg) // if brute damage
		if (tgt == "h") // is it a head or what?
			head_h = head_h - amm
			if(head_h <= 0)
				KillMe(1)
		if (tgt == "t")
			torso_h = torso_h - amm
			if(torso_h <= 0)
				KillMe(1)
		if (tgt == "la")
			l_arm_h = l_arm_h - amm
		if (tgt == "ra")
			r_arm_h = r_arm_h - amm
		if (tgt == "g")
			groin_h = groin_h - amm
		if (tgt == "ll")
			l_leg_h = l_leg_h - amm
		if (tgt == "rl")
			r_leg_h = r_leg_h - amm


	if (dmg == 1) // If something damages the lungs, bad air for example
		lunghealth = lunghealth - amm
	if (dmg == 2) // If something irradiates the player, will have some better effects later like hairloss and increased  hunger
		radloss = radloss + amm
	if (dmg == 3) // is some sort of chemical (read: alcohol) damaging the liver?
		chemloss = chemloss + amm
	if (dmg == 4) // The strain on the body caused by a virus or cancer or some shit.
		bioloss = bioloss + amm
	if (dmg == 5) // Ammount of fat consumed, if it reaches 100 you are fucked and you die
		hungerloss += amm

	if (lunghealth == 0 || radloss == 100 || chemloss == 100 || bioloss == 100 || hungerloss == 100)
		KillMe(1)

	if (l_leg_h <= 10 || r_leg_h <= 10) // Is the guys legs fucked up?
		canwalk = 0 // If yes, then OH GOD I CANT WALK
	/*else
		canwalk = 1*/ // other wise lol poo

	if (!l_leg_h && !r_leg_h) // are his legs so fucked up he cant even crawl?
		cancrawl = 0 // OH GOD NO HOPE LEFT
	/*else
		cancrawl = 1*/ // THERES STILL HOPE!

	if (l_arm_h <= 10) // does his hands fucking work? The next block of code is self explanatory since its the same jsut for the other hand.
		cangrasp_l = 0
	else
		cangrasp_l = 1

	if (r_arm_h <= 10)
		cangrasp_r = 0
	else
		cangrasp_r = 1

	if (HURTDBG)
		world << "OW! [name] was hurt!"

	return

mob/Move()
	if (stunned)
		return
	else
		..()

mob/proc/KillMe(drop)

	if (drop) // If the guy is in a state where dropping the items would make sence, eg. not gibbed :)
		var/obj/Objekt
		for(Objekt as obj in src)
			Objekt.loc = src.loc //drop shit

			//new/obj/comestible/corpse(src.loc)

			//new/turf/bloodstain(loc)
	else
		var/obj/Objekt
		for(Objekt as obj in src)
			del Objekt

	view() << "[src] KEELS OVER AND DIES!"

	loc = locate(/turf/start)
	ResetStats()


mob/proc/ResetStats()
	lunghealth = 100
	radloss = 0
	chemloss = 0
	bioloss = 0
	hungerloss = 0

	head_h = 100
	torso_h = 100
	l_arm_h = 100
	r_arm_h = 100
	groin_h = 100
	l_leg_h = 100
	r_leg_h = 100

	canwalk = 1
	cancrawl = 1
	cangrasp_l = 1
	cangrasp_r = 1

	basespd = 50
	spddiv = 2
	running = 0

	hunger = 100
	metabolism = 1
	starving = 0